home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / OSUtils.p < prev    next >
Text File  |  1996-05-01  |  12KB  |  472 lines

  1. {
  2.      File:        OSUtils.p
  3.  
  4.      Contains:    OS Utilities Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT OSUtils;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __OSUTILS__}
  28. {$SETC __OSUTILS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC OSUtilsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __MEMORY__}
  41. {$I Memory.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __PATCHES__}
  44. {$I Patches.p}
  45. {$ENDC}
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.  
  51.  
  52. CONST
  53.     useFree                        = 0;
  54.     useATalk                    = 1;
  55.     useAsync                    = 2;
  56.     useExtClk                    = 3;                            { Externally clocked }
  57.     useMIDI                        = 4;                            {  Machine Types  }
  58.     envMac                        = -1;
  59.     envXL                        = -2;
  60.     envMachUnknown                = 0;
  61.     env512KE                    = 1;
  62.     envMacPlus                    = 2;
  63.     envSE                        = 3;
  64.     envMacII                    = 4;
  65.     envMacIIx                    = 5;
  66.     envMacIIcx                    = 6;
  67.     envSE30                        = 7;
  68.     envPortable                    = 8;
  69.     envMacIIci                    = 9;
  70.     envMacIIfx                    = 11;                            {  CPU types  }
  71.     envCPUUnknown                = 0;
  72.  
  73.     env68000                    = 1;
  74.     env68010                    = 2;
  75.     env68020                    = 3;
  76.     env68030                    = 4;
  77.     env68040                    = 5;                            {  Keyboard types  }
  78.     envUnknownKbd                = 0;
  79.     envMacKbd                    = 1;
  80.     envMacAndPad                = 2;
  81.     envMacPlusKbd                = 3;
  82.     envAExtendKbd                = 4;
  83.     envStandADBKbd                = 5;
  84.     envPrtblADBKbd                = 6;
  85.     envPrtblISOKbd                = 7;
  86.     envStdISOADBKbd                = 8;
  87.     envExtISOADBKbd                = 9;
  88.     false32b                    = 0;                            { 24 bit addressing error }
  89.     true32b                        = 1;                            { 32 bit addressing error }
  90.                                                                 {  result types for RelString Call  }
  91.     sortsBefore                    = -1;                            { first string < second string }
  92.     sortsEqual                    = 0;                            { first string = second string }
  93.     sortsAfter                    = 1;                            { first string > second string }
  94.  
  95.                                                                 {  Toggle results  }
  96.     toggleUndefined                = 0;
  97.     toggleOK                    = 1;
  98.     toggleBadField                = 2;
  99.     toggleBadDelta                = 3;
  100.     toggleBadChar                = 4;
  101.     toggleUnknown                = 5;
  102.     toggleBadNum                = 6;
  103.     toggleOutOfRange            = 7;                            { synonym for toggleErr3 }
  104.     toggleErr3                    = 7;
  105.     toggleErr4                    = 8;
  106.     toggleErr5                    = 9;                            {  Date equates  }
  107.     smallDateBit                = 31;                            { Restrict valid date/time to range of Time global }
  108.     togChar12HourBit            = 30;                            { If toggling hour by char, accept hours 1..12 only }
  109.     togCharZCycleBit            = 29;                            { Modifier for togChar12HourBit: accept hours 0..11 only }
  110.     togDelta12HourBit            = 28;                            { If toggling hour up/down, restrict to 12-hour range (am/pm) }
  111.     genCdevRangeBit                = 27;                            { Restrict date/time to range used by genl CDEV }
  112.     validDateFields                = -1;
  113.     maxDateField                = 10;
  114.     eraMask                        = $0001;
  115.     yearMask                    = $0002;
  116.     monthMask                    = $0004;
  117.     dayMask                        = $0008;
  118.     hourMask                    = $0010;
  119.     minuteMask                    = $0020;
  120.     secondMask                    = $0040;
  121.     dayOfWeekMask                = $0080;
  122.     dayOfYearMask                = $0100;
  123.     weekOfYearMask                = $0200;
  124.     pmMask                        = $0400;
  125.     dateStdMask                    = $007F;                        { default for ValidDate flags and ToggleDate TogglePB.togFlags }
  126.  
  127.     eraField                    = 0;
  128.     yearField                    = 1;
  129.     monthField                    = 2;
  130.     dayField                    = 3;
  131.     hourField                    = 4;
  132.     minuteField                    = 5;
  133.     secondField                    = 6;
  134.     dayOfWeekField                = 7;
  135.     dayOfYearField                = 8;
  136.     weekOfYearField                = 9;
  137.     pmField                        = 10;
  138.     res1Field                    = 11;
  139.     res2Field                    = 12;
  140.     res3Field                    = 13;
  141.  
  142.  
  143. TYPE
  144.     LongDateField                        = SignedByte;
  145.  
  146. CONST
  147.     dummyType                    = 0;
  148.     vType                        = 1;
  149.     ioQType                        = 2;
  150.     drvQType                    = 3;
  151.     evType                        = 4;
  152.     fsQType                        = 5;
  153.     sIQType                        = 6;
  154.     dtQType                        = 7;
  155.     nmType                        = 8;
  156.  
  157.  
  158. TYPE
  159.     QTypes                                = SignedByte;
  160.     SysParmTypePtr = ^SysParmType;
  161.     SysParmType = PACKED RECORD
  162.         valid:                    UInt8;
  163.         aTalkA:                    UInt8;
  164.         aTalkB:                    UInt8;
  165.         config:                    UInt8;
  166.         portA:                    INTEGER;
  167.         portB:                    INTEGER;
  168.         alarm:                    LONGINT;
  169.         font:                    INTEGER;
  170.         kbdPrint:                INTEGER;
  171.         volClik:                INTEGER;
  172.         misc:                    INTEGER;
  173.     END;
  174.  
  175.     SysPPtr                                = ^SysParmType;
  176.     QElemPtr = ^QElem;
  177.     QElem = RECORD
  178.         qLink:                    QElemPtr;
  179.         qType:                    INTEGER;
  180.         qData:                    ARRAY [0..0] OF INTEGER;
  181.     END;
  182.  
  183.     QHdrPtr = ^QHdr;
  184.     QHdr = RECORD
  185.         qFlags:                    INTEGER;
  186.         qHead:                    QElemPtr;
  187.         qTail:                    QElemPtr;
  188.     END;
  189.  
  190. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  191.     DeferredTaskProcPtr = Register68kProcPtr;  { PROCEDURE DeferredTask(dtParam: LONGINT); }
  192.  
  193.     DeferredTaskUPP = UniversalProcPtr;
  194.     DeferredTaskPtr = ^DeferredTask;
  195.     DeferredTask = RECORD
  196.         qLink:                    QElemPtr;
  197.         qType:                    INTEGER;
  198.         dtFlags:                INTEGER;
  199.         dtAddr:                    DeferredTaskUPP;
  200.         dtParam:                LONGINT;
  201.         dtReserved:                LONGINT;
  202.     END;
  203.  
  204. {$ENDC}
  205.     MachineLocationPtr = ^MachineLocation;
  206.     MachineLocation = RECORD
  207.         latitude:                Fract;
  208.         longitude:                Fract;
  209.         CASE INTEGER OF
  210.         0: (
  211.             dlsDelta:            SInt8;                                    {  signed byte; daylight savings delta  }
  212.             );
  213.         1: (
  214.             gmtDelta:            LONGINT;                                {  use low 24-bits only  }
  215.             );
  216.     END;
  217.  
  218.     DateTimeRecPtr = ^DateTimeRec;
  219.     DateTimeRec = RECORD
  220.         year:                    INTEGER;
  221.         month:                    INTEGER;
  222.         day:                    INTEGER;
  223.         hour:                    INTEGER;
  224.         minute:                    INTEGER;
  225.         second:                    INTEGER;
  226.         dayOfWeek:                INTEGER;
  227.     END;
  228.  
  229.     LongDateTime                        = wide;
  230.     LongDateTimePtr                     = ^LongDateTime;
  231.     LongDateCvtPtr = ^LongDateCvt;
  232.     LongDateCvt = RECORD
  233.         CASE INTEGER OF
  234.         0: (
  235.             c:                    wide;
  236.             );
  237.         1: (
  238.             lHigh:                UInt32;
  239.             lLow:                UInt32;
  240.            );
  241.     END;
  242.  
  243.     LongDateRecPtr = ^LongDateRec;
  244.     LongDateRec = RECORD
  245.         CASE INTEGER OF
  246.         0: (
  247.             era:                INTEGER;
  248.             year:                INTEGER;
  249.             month:                INTEGER;
  250.             day:                INTEGER;
  251.             hour:                INTEGER;
  252.             minute:                INTEGER;
  253.             second:                INTEGER;
  254.             dayOfWeek:            INTEGER;
  255.             dayOfYear:            INTEGER;
  256.             weekOfYear:            INTEGER;
  257.             pm:                    INTEGER;
  258.             res1:                INTEGER;
  259.             res2:                INTEGER;
  260.             res3:                INTEGER;
  261.            );
  262.         1: (
  263.             list:                ARRAY [0..13] OF INTEGER;                { Index by LongDateField! }
  264.             );
  265.         2: (
  266.             eraAlt:                INTEGER;
  267.             oldDate:            DateTimeRec;
  268.            );
  269.     END;
  270.  
  271.     DateDelta                            = SInt8;
  272.     TogglePBPtr = ^TogglePB;
  273.     TogglePB = RECORD
  274.         togFlags:                LONGINT;                                { caller normally sets low word to dateStdMask=$7F }
  275.         amChars:                ResType;                                { from 'itl0', but uppercased }
  276.         pmChars:                ResType;                                { from 'itl0', but uppercased }
  277.         reserved:                ARRAY [0..3] OF LONGINT;
  278.     END;
  279.  
  280.     ToggleResults                        = INTEGER;
  281. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  282.  
  283. CONST
  284.     uppDeferredTaskProcInfo = $0000B802;
  285.  
  286. FUNCTION NewDeferredTaskProc(userRoutine: DeferredTaskProcPtr): DeferredTaskUPP;
  287.     {$IFC NOT GENERATINGCFM }
  288.     INLINE $2E9F;
  289.     {$ENDC}
  290.  
  291. PROCEDURE CallDeferredTaskProc(dtParam: LONGINT; userRoutine: DeferredTaskUPP);
  292.     {$IFC NOT GENERATINGCFM}
  293.     {To be implemented:  Glue to move parameters into registers.}
  294.     {$ENDC}
  295. {$ENDC}
  296. PROCEDURE LongDateToSeconds({CONST}VAR lDate: LongDateRec; VAR lSecs: LongDateTime);
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $2F3C, $8008, $FFF2, $A8B5;
  299.     {$ENDC}
  300. PROCEDURE LongSecondsToDate(VAR lSecs: LongDateTime; VAR lDate: LongDateRec);
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $2F3C, $8008, $FFF0, $A8B5;
  303.     {$ENDC}
  304. FUNCTION ToggleDate(VAR lSecs: LongDateTime; field: LongDateField; delta: DateDelta; ch: INTEGER; {CONST}VAR params: TogglePB): ToggleResults;
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $2F3C, $820E, $FFEE, $A8B5;
  307.     {$ENDC}
  308. FUNCTION ValidDate({CONST}VAR vDate: LongDateRec; flags: LONGINT; VAR newSecs: LongDateTime): INTEGER;
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $2F3C, $820C, $FFE4, $A8B5;
  311.     {$ENDC}
  312. FUNCTION IsMetric: BOOLEAN;
  313.     {$IFC NOT GENERATINGCFM}
  314.     INLINE $3F3C, $0004, $A9ED;
  315.     {$ENDC}
  316. FUNCTION GetSysPPtr: SysPPtr;
  317.     {$IFC NOT GENERATINGCFM}
  318.     INLINE $2EBC, $0000, $01F8;
  319.     {$ENDC}
  320. FUNCTION ReadDateTime(VAR time: LONGINT): OSErr;
  321.     {$IFC NOT GENERATINGCFM}
  322.     INLINE $205F, $A039, $3E80;
  323.     {$ENDC}
  324. PROCEDURE GetDateTime(VAR secs: LONGINT);
  325.     {$IFC NOT GENERATINGCFM}
  326.     INLINE $205F, $20B8, $020C;
  327.     {$ENDC}
  328. FUNCTION SetDateTime(time: LONGINT): OSErr;
  329.     {$IFC NOT GENERATINGCFM}
  330.     INLINE $201F, $A03A, $3E80;
  331.     {$ENDC}
  332. PROCEDURE SetTime({CONST}VAR d: DateTimeRec);
  333.     {$IFC NOT GENERATINGCFM}
  334.     INLINE $205F, $A9C7, $A03A;
  335.     {$ENDC}
  336. PROCEDURE GetTime(VAR d: DateTimeRec);
  337.     {$IFC NOT GENERATINGCFM}
  338.     INLINE $205F, $2038, $020C, $A9C6;
  339.     {$ENDC}
  340. PROCEDURE DateToSeconds({CONST}VAR d: DateTimeRec; VAR secs: LONGINT);
  341. PROCEDURE SecondsToDate(secs: LONGINT; VAR d: DateTimeRec);
  342.     {$IFC NOT GENERATINGCFM}
  343.     INLINE $205F, $201F, $A9C6;
  344.     {$ENDC}
  345. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  346. FUNCTION DTInstall(dtTaskPtr: DeferredTaskPtr): OSErr;
  347.     {$IFC NOT GENERATINGCFM}
  348.     INLINE $205F, $A082, $3E80;
  349.     {$ENDC}
  350. {$ENDC}
  351. FUNCTION GetMMUMode: SInt8;
  352.     {$IFC NOT GENERATINGCFM}
  353.     INLINE $1EB8, $0CB2;
  354.     {$ENDC}
  355. PROCEDURE SwapMMUMode(VAR mode: SInt8);
  356.     {$IFC NOT GENERATINGCFM}
  357.     INLINE $205F, $1010, $A05D, $1080;
  358.     {$ENDC}
  359. PROCEDURE Delay(numTicks: LONGINT; VAR finalTicks: LONGINT);
  360.     {$IFC NOT GENERATINGCFM}
  361.     INLINE $225F, $205F, $A03B, $2280;
  362.     {$ENDC}
  363. FUNCTION WriteParam: OSErr;
  364. PROCEDURE Enqueue(qElement: QElemPtr; qHeader: QHdrPtr);
  365.     {$IFC NOT GENERATINGCFM}
  366.     INLINE $225F, $205F, $A96F;
  367.     {$ENDC}
  368. FUNCTION Dequeue(qElement: QElemPtr; qHeader: QHdrPtr): OSErr;
  369.     {$IFC NOT GENERATINGCFM}
  370.     INLINE $225F, $205F, $A96E, $3E80;
  371.     {$ENDC}
  372. FUNCTION SetCurrentA5: LONGINT;
  373.     {$IFC NOT GENERATINGCFM}
  374.     INLINE $2E8D, $2A78, $0904;
  375.     {$ENDC}
  376. FUNCTION SetA5(newA5: LONGINT): LONGINT;
  377.     {$IFC NOT GENERATINGCFM}
  378.     INLINE $2F4D, $0004, $2A5F;
  379.     {$ENDC}
  380. FUNCTION InitUtil: OSErr;
  381.     {$IFC NOT GENERATINGCFM}
  382.     INLINE $A03F, $3E80;
  383.     {$ENDC}
  384. {$IFC GENERATINGPOWERPC }
  385. PROCEDURE MakeDataExecutable(baseAddress: UNIV Ptr; length: LONGINT);
  386. {$ENDC}
  387. {$IFC GENERATING68K }
  388. FUNCTION SwapInstructionCache(cacheEnable: BOOLEAN): BOOLEAN;
  389. PROCEDURE FlushInstructionCache;
  390.     {$IFC NOT GENERATINGCFM}
  391.     INLINE $7001, $A098;
  392.     {$ENDC}
  393. FUNCTION SwapDataCache(cacheEnable: BOOLEAN): BOOLEAN;
  394. PROCEDURE FlushDataCache;
  395.     {$IFC NOT GENERATINGCFM}
  396.     INLINE $7003, $A098;
  397.     {$ENDC}
  398. PROCEDURE FlushCodeCache;
  399.     {$IFC NOT GENERATINGCFM}
  400.     INLINE $A0BD;
  401.     {$ENDC}
  402. PROCEDURE FlushCodeCacheRange(address: UNIV Ptr; count: LONGINT);
  403.     {$IFC NOT GENERATINGCFM}
  404.     INLINE $225F, $205F, $7009, $A098;
  405.     {$ENDC}
  406. {$ENDC}
  407. PROCEDURE ReadLocation(VAR loc: MachineLocation);
  408.     {$IFC NOT GENERATINGCFM}
  409.     INLINE $205F, $203C, $000C, $00E4, $A051;
  410.     {$ENDC}
  411. PROCEDURE WriteLocation({CONST}VAR loc: MachineLocation);
  412.     {$IFC NOT GENERATINGCFM}
  413.     INLINE $205F, $203C, $000C, $00E4, $A052;
  414.     {$ENDC}
  415. {$IFC OLDROUTINENAMES }
  416. PROCEDURE LongDate2Secs({CONST}VAR lDate: LongDateRec; VAR lSecs: LongDateTime);
  417.     {$IFC NOT GENERATINGCFM}
  418.     INLINE $2F3C, $8008, $FFF2, $A8B5;
  419.     {$ENDC}
  420. PROCEDURE LongSecs2Date(VAR lSecs: LongDateTime; VAR lDate: LongDateRec);
  421.     {$IFC NOT GENERATINGCFM}
  422.     INLINE $2F3C, $8008, $FFF0, $A8B5;
  423.     {$ENDC}
  424. FUNCTION IUMetric: BOOLEAN;
  425.     {$IFC NOT GENERATINGCFM}
  426.     INLINE $3F3C, $0004, $A9ED;
  427.     {$ENDC}
  428. PROCEDURE Date2Secs({CONST}VAR d: DateTimeRec; VAR secs: LONGINT);
  429. PROCEDURE Secs2Date(secs: LONGINT; VAR d: DateTimeRec);
  430.     {$IFC NOT GENERATINGCFM}
  431.     INLINE $205F, $201F, $A9C6;
  432.     {$ENDC}
  433. {$ENDC}
  434. {$IFC OLDROUTINELOCATIONS }
  435. {  Environs Equates  }
  436.  
  437. CONST
  438.     curSysEnvVers                = 2;                            { Updated to equal latest SysEnvirons version }
  439.  
  440.  
  441. TYPE
  442.     SysEnvRecPtr = ^SysEnvRec;
  443.     SysEnvRec = RECORD
  444.         environsVersion:        INTEGER;
  445.         machineType:            INTEGER;
  446.         systemVersion:            INTEGER;
  447.         processor:                INTEGER;
  448.         hasFPU:                    BOOLEAN;
  449.         hasColorQD:                BOOLEAN;
  450.         keyBoardType:            INTEGER;
  451.         atDrvrVersNum:            INTEGER;
  452.         sysVRefNum:                INTEGER;
  453.     END;
  454.  
  455. {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED }
  456. FUNCTION SysEnvirons(versionRequested: INTEGER; VAR theWorld: SysEnvRec): OSErr;
  457.     {$IFC NOT GENERATINGCFM}
  458.     INLINE $205F, $301F, $A090, $3E80;
  459.     {$ENDC}
  460. {$ENDC}
  461. {$ENDC}
  462. {$ALIGN RESET}
  463. {$POP}
  464.  
  465. {$SETC UsingIncludes := OSUtilsIncludes}
  466.  
  467. {$ENDC} {__OSUTILS__}
  468.  
  469. {$IFC NOT UsingIncludes}
  470.  END.
  471. {$ENDC}
  472.